package com.gitee.wsl.scheduler.job.context

import com.gitee.wsl.scheduler.job.bean.ScheduledJob
import com.gitee.wsl.scheduler.job.dsl.JobDslMarker
import com.gitee.wsl.time.between
import kotlin.time.Duration
import kotlin.time.ExperimentalTime

@JobDslMarker
class CompletionJobContext internal constructor(
    private val scheduledJob: ScheduledJob
) {
    val jobName = scheduledJob.settings.name
    val jobId = scheduledJob.settings.id
    @OptIn(ExperimentalTime::class)
    fun time(): Duration = Duration.Companion.between(scheduledJob.progress.startedAt!!, scheduledJob.progress.completedAt!!)
}